package sjtu.rfid.rri.services.management;

import java.util.List;

import javax.jws.WebService;

import sjtu.rfid.rri.services.device.DeviceService;
import sjtu.rfid.rri.services.resolver.BundleException;
import sjtu.rfid.rri.services.resolver.BundleInfo;
import sjtu.rfid.rri.services.resolver.BundleState;

/**
 * The operation interface of ALEServer
 * 
 * @author jinghao
 * 
 */
@WebService
public interface ManagementProxy extends ALEOperation, DeviceService {

	// Web Services doesn't allow duplicate operation!
	// It doesn't support method overloading!
	// So we have to rename bundle operations here!
	// That's the reason I put BundleResolver operations here instead of
	// extends the BundleResolver!

	/**
	 * add bundle repository url
	 * 
	 * @param url
	 * @throws Exception
	 */
	void addRepository(String url) throws BundleException;

	/**
	 * get list of bundle repository urls
	 * 
	 */
	List<String> getRepository();

	/**
	 * 
	 * @return whether bundle repository is used
	 */
	boolean isUseBundleRepository();

	/**
	 * set whether to use bundle repository or not
	 * 
	 * @param useBundleRepository
	 */
	void setUseBundleRepository(boolean useBundleRepository);

	/**
	 * start the specified bundle without version information. (Currently I put
	 * 1.0.0 as version, equals startBundle(symbolicName, "1.0.0") )
	 * 
	 * @param symbolicName
	 * @throws BundleException
	 */
	void startBundle(String symbolicName) throws BundleException;

	/**
	 * start the specified bundle with version information.
	 * 
	 * @param symbolicName
	 * @param version
	 * @throws BundleException
	 */
	void startBundleWithVersion(String symbolicName, String version)
			throws BundleException;

	/**
	 * stop the specified bundle without version information. (Currently I put
	 * 1.0.0 as version, equals stopBundle(symbolicName, "1.0.0") )
	 * 
	 * @param symbolicName
	 * @throws BundleException
	 */
	void stopBundle(String symbolicName) throws BundleException;

	/**
	 * stop the specified bundle with version information.
	 * 
	 * @param symbolicName
	 * @param version
	 * @throws BundleException
	 */
	void stopBundleWithVersion(String symbolicName, String version)
			throws BundleException;

	/**
	 * restart the specified bundle without version information. (Currently I
	 * put 1.0.0 as version, equals stopBundle(symbolicName, "1.0.0") )
	 * 
	 * @param symbolicName
	 * @throws BundleException
	 */
	void restartBundle(String symbolicName) throws BundleException;

	/**
	 * restart the specified bundle with version information.
	 * 
	 * @param symbolicName
	 * @param version
	 * @throws BundleException
	 */
	void restartBundleWithVersion(String symbolicName, String version)
			throws BundleException;

	/**
	 * deploy the specified bundle without version information. (Currently I put
	 * 1.0.0 as version, equals deployBundle(symbolicName, "1.0.0") )
	 * 
	 * @param symbolicName
	 * @param version
	 */
	void deployBundle(String symbolicName);

	/**
	 * deploy the specified bundle with version information.
	 * 
	 * @param symbolicName
	 * @param version
	 */
	void deployBundleWithVersion(String symbolicName, String version);

	/**
	 * Get a list of BundleInfo according to the specified BundleState. <br>
	 * 
	 * @param state
	 *            the BundleState, pass null to return all BundleInfos.
	 * @return a list of BundleInfo according to the specified BundleState.
	 *         Returns an empty list if there exists no such BundleInfo.
	 */
	List<BundleInfo> getBundleInfos(BundleState state);

}
